<?php
require('./include/phpsqlajax_dbinfo.php');
	
	function parseToXML($htmlStr){
		$xmlStr=str_replace('&','&amp;',$htmlStr);
		return $xmlStr; 
	}
	
	 // Opens a connection to a MySQL server.
	$connection = mysql_connect ($server, $username, $password);
	if (!$connection) 
	{
	  die('Not connected : ' . mysql_error());
	}
	
	// Sets the active MySQL database.
	$db_selected = mysql_select_db($database, $connection);
	if (!$db_selected) 
	{
	  die ('Can\'t use db : ' . mysql_error());
	}
	
	 //Set result charset to UTF-8
	mysql_query('SET NAMES "utf8"');
	
	/*
	*Delete event and all connections to other tables
	*/
	if(isset($_POST['idEvent'])){
	
		//Keywords
		$deleteKeywords='DELETE FROM `keywords_has_events` WHERE `Events_idEvents`='.$_POST['idEvent'].'';
		mysql_query($deleteKeywords)or die (mysql_error());
		
		//Links
		$deleteLinks='DELETE FROM `links` WHERE `Events_idEvents`='.$_POST['idEvent'].'';
		mysql_query($deleteLinks)or die (mysql_error());
		
		//Event categories
		$deleteEventCategories='DELETE FROM `events_has_eventcategories` WHERE `Events_idEvents`='.$_POST['idEvent'].'';
		mysql_query($deleteEventCategories)or die (mysql_error());
		
		//Event information
		$deleteEvent='DELETE FROM `events` WHERE `idEvents`='.$_POST['idEvent'].'';
		mysql_query($deleteEvent)or die (mysql_error());
	}	
		
		
?>